Handling API Requests
-
An abstract class that represents a request to the Spotify Web API.
An
See moreSKRequest
object encapsulates the properties of an HTTP request, providing a convenient template for you to create, prepare, and send requests to the Web API. See the API Requests Guide for more details.Declaration
Swift
public class SKRequest
-
The callback handler for a request.
Declaration
Swift
public typealias SKRequestHandler = (_ data: Data?, _ status: SKResponseStatus?, _ error: Error?) -> Void
Parameters
data
The data (typically an encoded JSON object) returned by the request, if any. If the data returned represents an API-specific error object, that object will be provided via the
error
parameter instead.status
The API-specific HTTP status code associated with the response. If the underlying URL request could not be completed successfully, or the URL response contained an unexpected status code, this parameter will be
nil
.error
An error identifying if and why the request failed, or
nil
if the request was successful. -
The callback handler for a request.
Declaration
Swift
public typealias SKDecodableHandler<T> = (_ type: T?, _ error: Error?) -> Void
Parameters
type
The type decoded from the JSON data returned by the request. If the type could not be decoded from the data received, the
error
parameter will provide details.error
An error identifying if and why the request or decoding failed, or
nil
if the request was successful. -
The callback handler for a request.
Declaration
Swift
public typealias SKErrorHandler = (_ error: Error?) -> Void
Parameters
error
An error identifying if and why the request or decoding failed, or
nil
if the request was successful.
-
The Response Status Codes used by the Spotify Web API, as defined in the RFC 2616 and RFC 6585.
See moreDeclaration
Swift
public struct SKResponseStatus
-
Declaration
Swift
public struct SKError : Error, JSONDecodable
-
An authentication error returned by the Spotify Web API.
See also
The Web API Authentication Error object.Declaration
Swift
public struct SKAuthenticationError : Error, JSONDecodable